package com.hejing.List不同实现类的对比;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * ClassName: StudentTest
 * Package: com.hejing.List不同实现类的对比
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-05-18 9:32
 * @Version: 1.0
 */
public class StudentTest {
    public static void main(String[] args) {

        System.out.println("请录入学生信息: ");
        Scanner scan = new Scanner(System.in);
        List list = new ArrayList();

        while(true) {
            System.out.println("1: 继续录入，0: 结束录入");
            int selection = scan.nextInt();
            if(selection == 0) {
                break;
            }
            System.out.print("请输入学生姓名: ");
            String name = scan.next();
            System.out.print("请输入学生年龄: ");
            int age = scan.nextInt();

            // 封装数据:
            Student s = new Student(name, age);

            // 添加到集合
            list.add(s);

        }

        // 遍历集合中的学生信息:
        System.out.println("遍历学生信息: ");
        for(Object obj: list){
            System.out.println(obj);
        }

        scan.close();
    }
}

























